cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kman42
Level: Powered On

Help connecting to slack

I managed to create a connection to slack, but I'm having trouble posting and I haven't found any tutorials on the web. I'm starting with something super simple:

 

Slack.PostMessage("test_channel","test");

 

test_channel is a private channel, if that matters, and I am the only member. It doesn't show any errors in the code, but when I run it and come back, it gives me the following error message:

Slack.PostMessage failed: {"ok":false; "error":"not_authed"}

Do I need to join the channel first? I assumed not since the channel is specified in PostMessage. Do I have to post as myself rather than a bot since it is a private channel?

 

Thanks!

 

3 REPLIES 3
kman42
Level: Powered On

Re: Help connecting to slack

I managed to get the basic functionality after disconnecting and re-adding the connector, but I can't figure out how to pass a PowerApps field as the text. I want to do something like:

 

Slack.PostMessage("test_channel",ThisItem.Comments);

 

But it doesn't seem to like ThisItem. Any suggestions?

 

Thanks!

kman42
Level: Powered On

Re: Help connecting to slack

Sorry for the iterative messages, but there really isn't much info out there on using the Slack connector so maybe some of this will help someone else. I realized I was pulling from the wrong source

, so I can now get the basic message to post. I'm now having trouble with formatting, however. 

 

Slack.PostMessage("test","*Date:* " & DataCardValue15.SelectedDate & "*, Name:* " & LookUp('[DB',person_code=DataCardValue16.Text,name) & " \n " & DataCardValue14.Text);

For some reason, the "*Date:*" gets parsed to bold, but nothing after that does. I thought I could actually do something like "*Date: " & variable & ", Name: " & variable2 & "*" to bold the whole thing, but that doesn't work either.

v-yutliu-msft
Level 10

Re: Help connecting to slack

Hi @kman42 

Try this formula:

Slack.PostMessage("test",{ "*Date:* " : DataCardValue15.SelectedDate,
"*Name:* " : LookUp('[DB',person_code=DataCardValue16.Text,name) \n DataCardValue14.Text}
)

Here's doc about  it for your reference:

https://docs.microsoft.com/en-us/connectors/slack/

https://api.slack.com/docs/message-formatting

 

 

Best regards,

Community Support Team _ Phoebe Liu