aws-samples / amazon-connect-twitter-listener

MIT No Attribution
0 stars 2 forks source link

Don't see tasks created under Connect #1

Open gulshanmehta opened 2 years ago

gulshanmehta commented 2 years ago

Hi, trying to test this github, have done the deployment in our aws account, but don't see any tasks created under Connect based on keywords under monitoring as well as no cloudwatch logs under connect instance log group....can you advise if there is some to validate if the stack is deployed correctly , or any issues that could be causing no outputs post deployment...thanks

vpalomog commented 2 years ago

The CloudFormation console shows if all resources were created successfully. All resources are grouped under a Lambda application for easy access. If no other restrictions are on the account (such as SCPs) and everything else looks smooth:

  1. Double check the configuration provided in Secrets Manager (Twitter Streaming API credentials and Amazon Connect configuration).
  2. The TWITTER_TOPIC in the secret on Secrets Manager represents the filter for the Twitter stream, make sure you specify something such as: #AmazonConnectTwitterListener and use that same expression on your test tweets.
  3. The EC2 instance executes a Python3 script (located at /usr/local/twitter-streamer.py) as a service (named twitter-streamer) on boot. Log in to the EC2 and verify if the service is running correctly: systemctl status twitter-streamer Check the log of the service: sudo journalctl -u twitter-streamer.service

This could provide details on possible Twitter credentials erroring out (such as when accounts are placed on hold).

  1. Check the logs for the Stream Processor Lambda Function to confirm there are messages delivered from the stream and attempted to be delivered to the Contact Flow.

Hope this helps.

AWSJedi commented 1 year ago

@vpalomog : I am also getting Failed to start Twitter Streams Listener. Checked all details I am not sure on twitter side do we need anything else

AWSJedi commented 1 year ago

@vpalomog Please let me know if you have any update do you have this working ?

molopa commented 1 year ago

I recently updated the supported API version and added cloudwatch logging to get additional details. Make sure you also add the Bearer Token from Twitter.

Can you post what are you getting on executing this commands in the instance?

systemctl status twitter-streamer

Check the log of the service: sudo journalctl -u twitter-streamer.service

AWSJedi commented 1 year ago

Hi, I think twitter has now changed its policy to and if you want to use Twitter API 2.0 you need enterprise account which has some cost to it.Is your solution working ? Apr 12 03:35:01 ip-x.x.x.x.ec2.internal systemd[1]: twitter-streamer.service: main process exited, code=exited, status=1/FAILURE Apr 12 03:35:01 ip-x.x.x.x.ec2.internal systemd[1]: Unit twitter-streamer.service entered failed state. Apr 12 03:35:01 ip-x.x.x.x.ec2.internal systemd[1]: twitter-streamer.service failed. Apr 12 03:35:02 ip-x.x.x.x.ec2.internal systemd[1]: twitter-streamer.service holdoff time over, scheduling restart. Apr 12 03:35:02 ip-x.x.x.x.ec2.internal systemd[1]: Stopped Twitter Streams Listener. Apr 12 03:35:02 ip-x.x.x.x.ec2.internal systemd[1]: start request repeated too quickly for twitter-streamer.service Apr 12 03:35:02 iip-x.x.x.x.ec2.internal systemd[1]: Failed to start Twitter Streams Listener. Apr 12 03:35:02 iip-x.x.x.x.ec2.internal systemd[1]: Unit twitter-streamer.service entered failed state. Apr 12 03:35:02 ip-x.x.x.x.ec2.internal systemd[1]: twitter-streamer.service failed.

And logs

-- Logs begin at Sat 2023-04-08 04:54:10 UTC, end at Thu 2023-04-13 03:16:07 UTC. -- Apr 11 04:32:52 ip-x.x.x.x.ec2.internal systemd[1]: Started Twitter Streams Listener. Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: {'ResponseMetadata': {'RequestId': 'XXXX', 'HTTP Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: Traceback (most recent call last): Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: File "/usr/local/twitter-streamer.py", line 61, in Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: feedStream.add_rules(tweepy.StreamRule(topic)) Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: File "/usr/local/lib/python3.7/site-packages/tweepy/streaming.py", line 587, in Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: endpoint_parameters=("dry_run",), json=json, data_type=StreamRule Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: File "/usr/local/lib/python3.7/site-packages/tweepy/client.py", line 130, in _ma Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: json=json, user_auth=user_auth) Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: File "/usr/local/lib/python3.7/site-packages/tweepy/client.py", line 100, in req Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: raise Forbidden(response) Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: tweepy.errors.Forbidden: 403 Forbidden Apr 11 04:32:53 ip-x.x.x.x.ec2.internal python3[2314]: When authenticating requests to the Twitter API v2 endpoints, you must use keys Apr 11 04:32:53 ip-x.x.x.x.ec2.internal systemd[1]: twitter-streamer.service: main process exited, code=exited, status=1/FAILURE Apr 11 04:32:53 ip-x.x.x.x.ec2.internal systemd[1]: Unit twitter-streamer.service entered failed state. Apr 11 04:32:53 ip-x.x.x.x.ec2.internal systemd[1]: twitter-streamer.service failed. Apr 11 04:32:54 ip-x.x.x.x.ec2.internal systemd[1]: twitter-streamer.service holdoff time over, scheduling restart. Apr 11 04:32:54 ip-x.x.x.x.ec2.internal systemd[1]: Stopped Twitter Streams Listener. Apr 11 04:32:54 ip-x.x.x.x.ec2.internal systemd[1]: Started Twitter Streams Listener. Apr 11 04:32:54 ip-x.x.x.x.ec2.internal python3[2319]: Error creating CW Log group Apr 11 04:32:54 ip-x.x.x.x.ec2.internal python3[2319]: An error occurred (ResourceAlreadyExistsException) when calling the CreateLogGro Apr 11 04:32:54 ip-x.x.x.x.ec2.internal python3[2319]: {'ResponseMetadata': {'RequestId': 'XXXX', 'HTTP Apr 11 04:32:54 ip-x.x.x.x.ec2.internal python3[2319]: Traceback (most recent call last): Apr 11 04:32:54 ip-x.x.x.x.ec2.internal python3[2319]: File "/usr/local/twitter-streamer.py", line 61, in Apr 11 04:32:54 ip-x.x.x.x.ec2.internal python3[2319]: feedStream.add_rules(tweepy.StreamRule(topic))

I have used other scripts to test my authentication and it all valid and works.Please let me know