8

I am trying to send a message to a bot I created and published to azure services so that the bot can then start messaging some of its users.

I am trying to make the requests on Postman first so that then I can build a controller for that interaction.

I am doing the following request:

POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
Body:
grant_type:client_credentials
client_id: my_ms_app_id
client_secret: my_ms_app_secret
scope: https://api.botframework.com/.default

from this I get in the response the Bearer Authorization:

{
  "token_type": "Bearer",
  "expires_in": 3599,
  "ext_expires_in": 0,
  "access_token": "eyJ0eXA..."
}

Then I proceed with the following request:

POST https://skype.botframework.com/v3/conversations
Content-Type: application/json
Authorization: Bearer eyJ0eXAi....

{
    "bot": {
        "id": "i don't have this id so i pass some string",
        "name": "connector controller"
    },
    "isGroup": false,
    "members": [
        {
            "id": "28:...", //ID of the bot I want to send the message to
            "name": "Sp Bot"//Name of the bot I want to talk to
        },
       {
            "id": "i don't have this id so i pass some string",
            "name": "connector controller"
        }
    ],
    "topicName": "News Alert"
}

in response i get the conversation id which matches "id": "i don't have this id so i pass some string": { "id": "i don't have this id so i pass some string" }

Then I proceed with the following POST request:

POST. https://skype.botframework.com/v3/conversations/i don't have this id so i pass some string/activities
Authorization: Bearer eyJ0...
Content-Type:application/json

I get the following response:

400 Bad Request

{
  "error": {
    "code": "ServiceError",
    "message": "The conversationId 29... and bot .... doesn't match a known conversation"
  }
}

It looks like the problem occurs between the second and the 3 post method. It looks like that the https://skype.botframework.com/v3/conversations does not generate a conversation with the bot with Id I entered.

So when I make the final call to the bot: https://skype.botframework.com/v3/conversations/.../activities I always get the serviceError message.

2 Answers2

8

Based on your comments you are trying to create a custom "channel/client" to talk with the bot.

For doing that, I would recommend taking a look to Direct Line which seems the way to go for achieving your requirement.

I'm not sure which language are you using, so I will send you pointers to both C# and Node.

These are samples that will show you how to create custom client using Direct Line to interact with your bot:

C#

Node.js

All the samples are using a console app as the "custom channel".

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
4

Since you're going to make an app talk to your bot and most likely be using DirectLine after you and Ezequiel chatted, I created a series of screencaps on connecting to the DirectLine endpoint through Potsman. I'm going to assume that you know how to use environmental and global variables in Postman, here are Postman's documentation for other people's benefit. Also, the DirectLine v3.0 docs are here.

Below is a capture of the directline endpoint you would request a token from, {{DLsecret}}'s guts looks like this, Bearer <your-dl-secret>: Call #1 Headers

Here is an example of the response body you would receive on a valid call: Call #1 Response Body

You may have noticed that I have some test results, in the screenshow below it has five (vs four) tests because I added the test verifying that the conversationId was set in the environment variables: Call #1 Tests and Results

Here's the second query sent, which contains an actual message: Call #2 Headers

This is the request body which has the message: Call #2 Request Body (The message)

And here is the response body: Call #3 Response Body

Steven G.
  • 1,632
  • 1
  • 11
  • 14