ARI Scripts

Hello, I am trying to implement a python script to react to channel states and initiate system actions. I have followed the Asterisk tutorials but I can’t seem to figure where to drop my script… or if that’s a non-issue, why the ARI module cannot load.

Thanks and regards.

Before 15 ARI has to be enabled in advanced settings.

Thank you for the message. I had enabled the REST Interface previously so it doesn’t seem to be the cause. I don’t know if there is anything I can add to help you help me but I’ll happily comply.

the “next best” thing is to probably post your script via pastebin

The code is simply the channel-dump.py example from the Introduction to ARI and Channels. I’ve added some clutter like unused vars I want to use later and comments so I don’t need the wiki page to follow the code. The exact python error is:

[root@Singapore ~]# python /home/ast_scripts/create_engagement_call.py
Traceback (most recent call last):
  File "/home/ast_scripts/create_engagement_call.py", line 3, in <module>
    import ari
ImportError: No module named ari

(I also get a “new users can’t post links” problem so…)

You need the ari library
pip install ari or something similar

Ok the ari library is installed but it seems like it has problems too.

Traceback (most recent call last):
  File "/var/lib/asterisk/bin/create_engagement_call.py", line 3, in <module>
    import ari
  File "/usr/lib/python2.6/site-packages/ari/__init__.py", line 8, in <module>
    import client
  File "/usr/lib/python2.6/site-packages/ari/client.py", line 32
    for (name, api) in self.swagger.resources.items()}
      ^
SyntaxError: invalid syntax

I think the most tested and used client is in node

1 Like

I’m not sure I understand. Do you mean I am lacking a client? Or that I am not using it correctly?

Sorry client library is probably a more accurate term.
I have never used the python library so I couldn’t say if it is being used properly

You could use something like: https://gist.github.com/jfinstrom/1ba8706bd3749bfc4596dedeb5470c5b
To ensure ARI is working correctly.

This doesn’t test your code or the library but it will tell you ARI is enabled and responding.

Sorry for the silence, priority dropped for a few days.

Thank you for the script. According to it ARI is working.