# SyntaxError in agent handle\_text

**URL:** <https://forum.rasa.com/t/syntaxerror-in-agent-handle-text/14119>\
**Category:** Rasa Open Source\
**Created:** [August 9, 2019, 2:22am UTC](https://forum.rasa.com/t/syntaxerror-in-agent-handle-text/14119 "2019-08-09T02:22:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![coderlxn](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/coderlxn/32/2479_2.png) [@coderlxn](https://forum.rasa.com/u/coderlxn)\
**Post date:** [August 9, 2019, 2:22am UTC](https://forum.rasa.com/t/syntaxerror-in-agent-handle-text/14119/1 "2019-08-09T02:22:56Z")

</div>

OS: Linux 4.9.184-linuxkit

Python: 3.6.7

I tried to run the example of agent in Rasa Docs. [https://rasa.com/docs/rasa/api/agent/#rasa.core.agent.Agent.handle\_text](https://rasa.com/docs/rasa/api/agent/#rasa.core.agent.Agent.handle_text)

> from rasa.core.agent import Agent

> from rasa.core.interpreter import RasaNLUInterpreter

> agent = Agent.load(“examples/restaurantbot/models/current”)

> await agent.handle\_text(“hello”)

> [u’how can I help you?']

But it came to an SyntaxError: invalid syntax.

 ![QQ20190809-102225](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/c/c02de357296fa60dba6b0fc07f7eff4c8dca7698.png)

Is anyone can help me?

---

<div class="post-metadata">

**Author:** ![MetcalfeTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/metcalfetom/32/1422_2.png) [@MetcalfeTom](https://forum.rasa.com/u/MetcalfeTom)\
**Post date:** [August 9, 2019, 6:49am UTC](https://forum.rasa.com/t/syntaxerror-in-agent-handle-text/14119/2 "2019-08-09T06:49:42Z")

</div>

Oops! Looks like our docs are incorrect there, thanks for bringing this up!

You need to import `asyncio` and run `handle_message` within the events loop, for instance with:

```auto
 import asyncio
asyncio.run(ag.handle_text('hi'))
[{'recipient_id': 'default', 'text': 'Hey! How are you?'}]

```

---

<div class="post-metadata">

**Author:** ![coderlxn](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/coderlxn/32/2479_2.png) [@coderlxn](https://forum.rasa.com/u/coderlxn)\
**Post date:** [August 12, 2019, 6:39am UTC](https://forum.rasa.com/t/syntaxerror-in-agent-handle-text/14119/3 "2019-08-12T06:39:42Z")

</div>

Thx, `asyncio.run(ag.handle_text('hi'))` works after I upgrade python version to 3.7.4.
