ARI. TextMessageReceived

Hello, I am trying to handle SIP MESSAGE in ARI. But no success, can you, please assist me?

Asterisk receives MESSAGE, answers 202 OK, and sends event StasisStart instead of TextMessageReceived. There are no endpoints. I just want to receive MESSAGE and get body in my application

my python aioari application:

loop = asyncio.get_event_loop()
client = loop.run_until_complete(aioari.connect(ast_url, ast_username, ast_password, loop=loop))
client.on_event("TextMessageReceived", on_message)
client.on_channel_event('StasisStart', on_start)
client.on_channel_event('StasisEnd', on_end)
<--- Sending ARI event to 10.101.14.8:38436 --->
{
  "type": "StasisStart",
  "timestamp": "2021-08-12T12:56:10.521+0000",
  "args": [],
  "channel": {
    "id": "asterisk-1628772970.0",
    "name": "Message/ast_msg_queue",
    "state": "Up",
    "caller": {
      "name": "",
      "number": ""
    },
    "connected": {
      "name": "",
      "number": ""
    },
    "accountcode": "",
    "dialplan": {
      "context": "stasis-hello",
      "exten": "aaa",
      "priority": 1,
      "app_name": "Stasis",
      "app_data": "hello"
    },
    "creationtime": "2021-08-12T12:56:10.521+0000",
    "language": "ru"
  },
  "asterisk_id": "2e:2a:81:41:5a:27",
  "application": "hello"
}

You do not configure the dialplan to send the message channel to ARI. You subscribe to the endpoint, or the channel technology[1], and then will receive TextMessageReceived.

[1] Asterisk 18 Applications REST API - Asterisk Project - Asterisk Project Wiki

Thank you for answer,

what do you mean “to configure” dialplan? should I write something in extensions.conf? I have dynamic context: context = stasis-hello

I have subscribe my application from swager, but asterisk send only StasisStart:

Having never explicitly done this in quite a long time, I don’t recall any further. Someone else may have additional input or done it - I vaguely recall someone else posting about it.

I will say regardless of that, you don’t want the message channel going to ARI. You could send it to another context that just does NoOp, but sending it to ARI isn’t going to end well.

I’m sorry, I’m not sure that I understand you right, perhaps because my English is not good, so you do not recomend to use MESSAGE with ARI?

When a message is received it goes to the dialplan. What I’m saying is do not send it to your ARI application in the dialplan. It’s not made for that, and you could run into issues. This is why the TextMessageReceived functionality exists which is outside of that.

hmm… I don’t send SIP MESSAGE from my dialplan to ARI application… I just want asterisk to send TextMessageReceived event, when asterisk receive MESSAGE

now asterisk for some reason send StasisStart

I don’t have any dialplan at all. context creates automayilcally after python application is conected to asterisk

That would be why. Your out of call message requests are going to it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.